﻿using DAL;
using System;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace MainOP
{
    public partial class FormDesplay2 : Form
    {

        public FormDesplay2()
        {
            InitializeComponent();

        }

        void drow()
        {
            string[] x = new string[] { "OP10", "OP20", "OP30", "OP40", "OP50", "OP60", "OP70", "OP80", "OP90", "OP100"};/*,"OP110"*/
            double[] y = new double[] { FormMain.OP10[0], /*FormMain.OP10_2[0],*/ FormMain.OP20[0], FormMain.OP30[0], FormMain.OP40[0], FormMain.OP50[0], FormMain.OP60[0], FormMain.OP70[0], FormMain.OP80[0], FormMain.OP90[0], FormMain.OP100[0]/*, FormMain.OP110[0]*/};
            //double[] y = new double[] { 20, 30, 50, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105 };

            //string[] xCount = new string[] { "OP10", "OP20", "OP30", "OP40", "OP50", "OP60", "OP70", "OP80", "OP90", "OP100"/*, "OP110"*/ };
            //double[] yCount = new double[] { FormMain.OP10[1], /*FormMain.OP10_2[1],*/ FormMain.OP20[1], FormMain.OP30[1], FormMain.OP40[1], FormMain.OP50[1], FormMain.OP60[1], FormMain.OP70[1], FormMain.OP80[1], FormMain.OP90[1], FormMain.OP100[1]/*, FormMain.OP110[1]*/};
            string[] xCount = new string[] { FormMain.TimeRange[0], FormMain.TimeRange[1], FormMain.TimeRange[2], FormMain.TimeRange[3], FormMain.TimeRange[4], FormMain.TimeRange[5], FormMain.TimeRange[6], FormMain.TimeRange[7], FormMain.TimeRange[8], FormMain.TimeRange[9], FormMain.TimeRange[10], FormMain.TimeRange[11] };
            double[] yCount = new double[] { FormMain.TimeRangeValue[0], FormMain.TimeRangeValue[1], FormMain.TimeRangeValue[2], FormMain.TimeRangeValue[3], FormMain.TimeRangeValue[4], FormMain.TimeRangeValue[5], FormMain.TimeRangeValue[6], FormMain.TimeRangeValue[7], FormMain.TimeRangeValue[8], FormMain.TimeRangeValue[9], FormMain.TimeRangeValue[10], FormMain.TimeRangeValue[11] };
            //double[] yCount = new double[] { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 38, 37 };

            string[] xUtilization = new string[] { "OP10", "OP20", "OP30", "OP40", "OP50", "OP60", "OP70", "OP80", "OP90", "OP100"/*, "OP110" */};
            double[] yUtilization = new double[] { FormMain.OP10[2],/* FormMain.OP10_2[2],*/ FormMain.OP20[2], FormMain.OP30[2], FormMain.OP40[2], FormMain.OP50[2], FormMain.OP60[2], FormMain.OP70[2], FormMain.OP80[2], FormMain.OP90[2], FormMain.OP100[2]/*, FormMain.OP110[2]*/};

            string[] xCycleTime = new string[] { "OP10", "OP20", "OP30", "OP40", "OP50", "OP60", "OP70", "OP80", "OP90", "OP100"/*, "OP110"*/ };
            double[] yCycleTime = new double[] { FormMain.OP10[3],/* FormMain.OP10_2[3],*/ FormMain.OP20[3], FormMain.OP30[3], FormMain.OP40[3], FormMain.OP50[3], FormMain.OP60[3], FormMain.OP70[3], FormMain.OP80[3], FormMain.OP90[3], FormMain.OP100[3]/*, FormMain.OP110[3]*/};
            #region 合格率

            //标题
            cht1.Titles.Add("当班合格率柱状图数据分析");
            cht1.Titles[0].ForeColor = Color.White;
            cht1.Titles[0].Font = new Font("宋体", 20, FontStyle.Regular);
            cht1.Titles[0].Alignment = ContentAlignment.TopCenter;

            //右上角标题
            cht1.Titles.Add("一次合格率："+FormMain.YCok[0]);
            //cht1.Titles.Add("合计：25414 宗");
            //cht1.Titles.Add("合计：25414 宗");
            //cht1.Titles.Add("合计：25414 宗");
            cht1.Titles[1].ForeColor = Color.White;
            cht1.Titles[1].Font = new Font("宋体", 20, FontStyle.Regular);
            //设置标题位于右上角
            cht1.Titles[1].Alignment = ContentAlignment.TopLeft;
            //cht1.Titles[2].Alignment = ContentAlignment.TopRight;
            //cht1.Titles[3].Alignment = ContentAlignment.TopRight;
            //cht1.Titles[4].Alignment = ContentAlignment.TopRight;

            //控件背景
            cht1.BackColor = Color.Transparent;
            //图表区背景
            cht1.ChartAreas[0].BackColor = Color.Transparent;
            cht1.ChartAreas[0].BorderColor = Color.Transparent;
            //X轴标签间距
            cht1.ChartAreas[0].AxisX.Interval = 1;
            cht1.ChartAreas[0].AxisX.LabelStyle.IsStaggered = true;
            cht1.ChartAreas[0].AxisX.LabelStyle.Angle = -45;   //下方标签显示的角度
            cht1.ChartAreas[0].AxisX.TitleFont = new Font("微软雅黑", 20, FontStyle.Regular);
            cht1.ChartAreas[0].AxisX.TitleForeColor = Color.White;

            //X坐标轴颜色
            cht1.ChartAreas[0].AxisX.LineColor = ColorTranslator.FromHtml("#38587a"); ;
            cht1.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.White;
            cht1.ChartAreas[0].AxisX.LabelStyle.Font = new Font("宋体", 20, FontStyle.Regular);
            //X坐标轴标题
            cht1.ChartAreas[0].AxisX.Title = "工位";
            cht1.ChartAreas[0].AxisX.TitleFont = new Font("宋体", 20, FontStyle.Regular);
            cht1.ChartAreas[0].AxisX.TitleForeColor = Color.White;
            cht1.ChartAreas[0].AxisX.TextOrientation = TextOrientation.Horizontal;
            cht1.ChartAreas[0].AxisX.ToolTip = "工位";
            //X轴网络线条
            cht1.ChartAreas[0].AxisX.MajorGrid.Enabled = true;
            cht1.ChartAreas[0].AxisX.MajorGrid.LineColor = ColorTranslator.FromHtml("#2c4c6d");

            //Y坐标轴颜色
            cht1.ChartAreas[0].AxisY.LineColor = ColorTranslator.FromHtml("#38587a");
            cht1.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.White;
            cht1.ChartAreas[0].AxisY.LabelStyle.Font = new Font("宋体", 20, FontStyle.Regular);
            //Y坐标轴标题
            cht1.ChartAreas[0].AxisY.Title = "合格率(%)";
            cht1.ChartAreas[0].AxisY.TitleFont = new Font("宋体", 15, FontStyle.Regular);
            cht1.ChartAreas[0].AxisY.TitleForeColor = Color.White;
            cht1.ChartAreas[0].AxisY.TextOrientation = TextOrientation.Rotated270;
            cht1.ChartAreas[0].AxisY.ToolTip = "合格率(%)";
            //Y轴网格线条
            cht1.ChartAreas[0].AxisY.MajorGrid.Enabled = true;
            cht1.ChartAreas[0].AxisY.MajorGrid.LineColor = ColorTranslator.FromHtml("#2c4c6d");
            cht1.ChartAreas[0].AxisY.Maximum = 100;

            cht1.ChartAreas[0].AxisY2.LineColor = Color.Transparent;
            cht1.ChartAreas[0].BackGradientStyle = GradientStyle.TopBottom;
            string now_time = System.DateTime.Now.ToString("d");
            Legend legend = new Legend(now_time);
            legend.Title = "legendTitle";

            cht1.Series[0].XValueType = ChartValueType.String;  //设置X轴上的值类型
            cht1.Series[0].Label = "#VAL";                //设置显示X Y的值    
            cht1.Series[0].Font = new Font("宋体", 20, FontStyle.Regular);
            cht1.Series[0].LabelForeColor = Color.White;
            cht1.Series[0].ToolTip = "#VALX:#VAL";     //鼠标移动到对应点显示数值
            cht1.Series[0].ChartType = SeriesChartType.Column;    //图类型(柱状图)
            
            cht1.Series[0].Color = Color.Lime;
            cht1.Series[0].LegendText = legend.Name;
            cht1.Series[0].IsValueShownAsLabel = true;
            cht1.Series[0].LabelForeColor = Color.White;
            cht1.Series[0].CustomProperties = "DrawingStyle = Cylinder";
            cht1.Legends.Add(legend);
            cht1.Legends[0].Position.Auto = false;
            
            //绑定数据
            cht1.Series[0].Points.DataBindXY(x, y);
            cht1.Series[0].Points[0].Color = Color.White;
            cht1.Series[0].Palette = ChartColorPalette.Bright;

            #endregion

            #region 节拍

            //标题
            cht2.Titles.Add("生产节拍数据分析");
            cht2.Titles[0].ForeColor = Color.White;
            cht2.Titles[0].Font = new Font("微软雅黑", 20, FontStyle.Regular);
            cht2.Titles[0].Alignment = ContentAlignment.TopCenter;
            //cht2.Titles.Add("合计：50" +
            //    "");
            //cht2.Titles[1].ForeColor = Color.White;
            //cht2.Titles[1].Font = new Font("微软雅黑", 8f, FontStyle.Regular);
            //cht2.Titles[1].Alignment = ContentAlignment.TopRight;

            //控件背景
            cht2.BackColor = Color.Transparent;
            //图表区背景
            cht2.ChartAreas[0].BackColor = Color.Transparent;
            cht2.ChartAreas[0].BorderColor = Color.Transparent;
            //X轴标签间距
            cht2.ChartAreas[0].AxisX.Interval = 1;
            cht2.ChartAreas[0].AxisX.LabelStyle.IsStaggered = true;
            cht2.ChartAreas[0].AxisX.LabelStyle.Angle = -45;
            cht2.ChartAreas[0].AxisX.TitleFont = new Font("微软雅黑", 20, FontStyle.Regular);
            cht2.ChartAreas[0].AxisX.TitleForeColor = Color.White;

            //X坐标轴颜色
            cht2.ChartAreas[0].AxisX.LineColor = ColorTranslator.FromHtml("#38587a"); ;
            cht2.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.White;
            cht2.ChartAreas[0].AxisX.LabelStyle.Font = new Font("微软雅黑", 20, FontStyle.Regular);
            //X坐标轴标题
            cht2.ChartAreas[0].AxisX.Title = "工位";
            cht2.ChartAreas[0].AxisX.TitleFont = new Font("微软雅黑", 20, FontStyle.Regular);
            cht2.ChartAreas[0].AxisX.TitleForeColor = Color.White;
            cht2.ChartAreas[0].AxisX.TextOrientation = TextOrientation.Horizontal;
            cht2.ChartAreas[0].AxisX.ToolTip = "工位";
            //X轴网络线条
            cht2.ChartAreas[0].AxisX.MajorGrid.Enabled = true;
            cht2.ChartAreas[0].AxisX.MajorGrid.LineColor = ColorTranslator.FromHtml("#2c4c6d");

            //Y坐标轴颜色
            cht2.ChartAreas[0].AxisY.LineColor = ColorTranslator.FromHtml("#38587a");
            cht2.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.White;
            cht2.ChartAreas[0].AxisY.LabelStyle.Font = new Font("微软雅黑", 20, FontStyle.Regular);
            //Y坐标轴标题
            cht2.ChartAreas[0].AxisY.Title = "时间(S)";
            cht2.ChartAreas[0].AxisY.TitleFont = new Font("微软雅黑", 20, FontStyle.Regular);
            cht2.ChartAreas[0].AxisY.TitleForeColor = Color.White;
            cht2.ChartAreas[0].AxisY.TextOrientation = TextOrientation.Rotated270;
            cht2.ChartAreas[0].AxisY.ToolTip = "时间(S)";
            //Y轴网格线条
            cht2.ChartAreas[0].AxisY.MajorGrid.Enabled = true;
            cht2.ChartAreas[0].AxisY.MajorGrid.LineColor = ColorTranslator.FromHtml("#2c4c6d");

            cht2.ChartAreas[0].AxisY2.LineColor = Color.Transparent;

            //背景渐变
            cht2.ChartAreas[0].BackGradientStyle = GradientStyle.None;

            //图例样式
            Legend legend2 = new Legend("#VALX");
            legend2.Title = "图例";
            legend2.TitleBackColor = Color.Transparent;
            legend2.BackColor = Color.Transparent;
            legend2.TitleForeColor = Color.White;
            legend2.TitleFont = new Font("微软雅黑", 20, FontStyle.Regular);
            legend2.Font = new Font("微软雅黑", 20, FontStyle.Regular);
            legend2.ForeColor = Color.White;

            cht2.Series[0].XValueType = ChartValueType.String;  //设置X轴上的值类型
            cht2.Series[0].Label = "#VAL";                //设置显示X Y的值 
            cht2.Series[0].Font = new Font("微软雅黑", 20, FontStyle.Regular);
            cht2.Series[0].LabelForeColor = Color.White;
            cht2.Series[0].ToolTip = "#VALX:#VAL(S)";     //鼠标移动到对应点显示数值
            cht2.Series[0].ChartType = SeriesChartType.Line;    //图类型(折线)

            cht2.Series[0].Color = Color.Lime;
            cht2.Series[0].LegendText = legend2.Name;
            cht2.Series[0].IsValueShownAsLabel = true;
            cht2.Series[0].LabelForeColor = Color.White;
            cht2.Series[0].CustomProperties = "DrawingStyle = Cylinder";
            cht2.Series[0].CustomProperties = "PieLabelStyle = Outside";
            //cht2.Legends.Add(legend2);
            cht2.Legends[0].Position.Auto = false;
            cht2.Series[0].IsValueShownAsLabel = true;
            //是否显示图例
            cht2.Series[0].IsVisibleInLegend = true;
            cht2.Series[0].ShadowOffset = 0;

            //饼图折线
            cht2.Series[0]["PieLineColor"] = "White";
            //绑定数据
            cht2.Series[0].Points.DataBindXY(xCycleTime, yCycleTime);
            cht2.Series[0].Points[0].Color = Color.White;
            //绑定颜色
            //cht2.Series[0].Palette = ChartColorPalette.Bright;
            #endregion

            #region Bar图

            //标题
            cht3.Titles.Add("工位节拍实时排名");
            cht3.Titles[0].ForeColor = Color.White;
            cht3.Titles[0].Font = new Font("微软雅黑", 12f, FontStyle.Regular);
            cht3.Titles[0].Alignment = ContentAlignment.TopCenter;
            //cht3.Titles.Add("合计： ");
            //cht3.Titles[1].ForeColor = Color.White;
            //cht3.Titles[1].Font = new Font("微软雅黑", 8f, FontStyle.Regular);
            //cht3.Titles[1].Alignment = ContentAlignment.TopRight;

            //控件背景
            cht3.BackColor = Color.Transparent;
            //图表区背景
            cht3.ChartAreas[0].BackColor = Color.Transparent;
            cht3.ChartAreas[0].BorderColor = Color.Transparent;
            //X轴标签间距
            cht3.ChartAreas[0].AxisX.Interval = 1;
            cht3.ChartAreas[0].AxisX.LabelStyle.IsStaggered = true;
            cht3.ChartAreas[0].AxisX.LabelStyle.Angle = -45;
            cht3.ChartAreas[0].AxisX.TitleFont = new Font("微软雅黑", 14f, FontStyle.Regular);
            cht3.ChartAreas[0].AxisX.TitleForeColor = Color.White;

            //X坐标轴颜色
            cht3.ChartAreas[0].AxisX.LineColor = ColorTranslator.FromHtml("#38587a"); ;
            cht3.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.White;
            cht3.ChartAreas[0].AxisX.LabelStyle.Font = new Font("微软雅黑", 10f, FontStyle.Regular);
            //X坐标轴标题
            //cht3.ChartAreas[0].AxisX.Title = "数量(宗)";
            //cht3.ChartAreas[0].AxisX.TitleFont = new Font("微软雅黑", 10f, FontStyle.Regular);
            //cht3.ChartAreas[0].AxisX.TitleForeColor = Color.White;
            //cht3.ChartAreas[0].AxisX.TextOrientation = TextOrientation.Auto;
            //cht3.ChartAreas[0].AxisX.ToolTip = "数量(宗)";
            //X轴网络线条
            cht3.ChartAreas[0].AxisX.MajorGrid.Enabled = true;
            cht3.ChartAreas[0].AxisX.MajorGrid.LineColor = ColorTranslator.FromHtml("#2c4c6d");

            //Y坐标轴颜色
            cht3.ChartAreas[0].AxisY.LineColor = ColorTranslator.FromHtml("#38587a");
            cht3.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.White;
            cht3.ChartAreas[0].AxisY.LabelStyle.Font = new Font("微软雅黑", 10f, FontStyle.Regular);
            //Y坐标轴标题
            //cht3.ChartAreas[0].AxisY.Title = "数量(宗)";
            //cht3.ChartAreas[0].AxisY.TitleFont = new Font("微软雅黑", 10f, FontStyle.Regular);
            //cht3.ChartAreas[0].AxisY.TitleForeColor = Color.White;
            //cht3.ChartAreas[0].AxisY.TextOrientation = TextOrientation.Auto;
            //cht3.ChartAreas[0].AxisY.ToolTip = "数量(宗)";
            //Y轴网格线条
            cht3.ChartAreas[0].AxisY.MajorGrid.Enabled = true;
            cht3.ChartAreas[0].AxisY.MajorGrid.LineColor = ColorTranslator.FromHtml("#2c4c6d");

            cht3.ChartAreas[0].AxisY2.LineColor = Color.Transparent;
            cht3.ChartAreas[0].AxisX.IsMarginVisible = false;
            cht3.ChartAreas[0].Area3DStyle.Enable3D = true;
            //背景渐变
            cht2.ChartAreas[0].BackGradientStyle = GradientStyle.None;

            //图例样式
            Legend legend3 = new Legend("#VALX");
            legend3.Title = "图例";
            legend3.TitleBackColor = Color.Transparent;
            legend3.BackColor = Color.Transparent;
            legend3.TitleForeColor = Color.White;
            legend3.TitleFont = new Font("微软雅黑", 10f, FontStyle.Regular);
            legend3.Font = new Font("微软雅黑", 8f, FontStyle.Regular);
            legend3.ForeColor = Color.White;

            cht3.Series[0].XValueType = ChartValueType.String;  //设置X轴上的值类型
            cht3.Series[0].Label = "#VAL";                //设置显示X Y的值 
            cht3.Series[0].Font = new Font("微软雅黑", 20, FontStyle.Regular);
            cht3.Series[0].LabelForeColor = Color.White;
            cht3.Series[0].ToolTip = "#VALX:#VAL(S)";     //鼠标移动到对应点显示数值
            cht3.Series[0].ChartType = SeriesChartType.Bar;    //图类型(折线)

            cht3.Series[0].Color = Color.Lime;
            cht3.Series[0].LegendText = legend3.Name;
            cht3.Series[0].IsValueShownAsLabel = true;
            cht3.Series[0].LabelForeColor = Color.White;
            cht3.Series[0].CustomProperties = "DrawingStyle = Cylinder";
            cht3.Series[0].CustomProperties = "PieLabelStyle = Outside";
            //cht3.Legends.Add(legend3);
            cht3.Legends[0].Position.Auto = false;

            //是否显示图例
            cht3.Series[0].IsVisibleInLegend = true;
            cht3.Series[0].ShadowOffset = 0;

            //饼图折线
            cht3.Series[0]["PieLineColor"] = "White";
            //绑定数据
            cht3.Series[0].Points.DataBindXY(x, y);

            //cht3.Series[0].Points[0].Color = Color.White;
            //绑定颜色
            cht3.Series[0].Palette = ChartColorPalette.BrightPastel;

            //for (int n = 0; n < x.Length; n++)
            //{
            //    int ptIdx = cht3.Series[0].Points.AddY(Convert.ToDouble(y[n]));
            //    DataPoint pt = this.cht3.Series[0].Points[ptIdx];
            //    pt.LegendText = x[n] + " " + "#PERCENT{P2}" + " [ " + "#VAL{D} 次" + " ]";//右边标签列显示的文字  
            //    pt.Label = x[n] + " " + "#PERCENT{P2}" + " [ " + "#VAL{D} 次" + " ]"; //圆饼外显示的信息 

            //    //  pt.LabelToolTip = "#PERCENT{P2}";  
            //    //pt.LabelBorderColor = Color.Red;//文字背景色   
            //}

            #endregion

            #region 生产数量

            //标题
            cht4.Titles.Add("当班生产数量数据分析");
            cht4.Titles[0].ForeColor = Color.White;
            cht4.Titles[0].Font = new Font("微软雅黑", 20, FontStyle.Regular);
            cht4.Titles[0].Alignment = ContentAlignment.TopCenter;
            //cht4.Titles.Add("合计：50" +
            //    "");
            //cht4.Titles[1].ForeColor = Color.White;
            //cht4.Titles[1].Font = new Font("微软雅黑", 8f, FontStyle.Regular);
            //cht4.Titles[1].Alignment = ContentAlignment.TopRight;

            //控件背景
            cht4.BackColor = Color.Transparent;
            //图表区背景
            cht4.ChartAreas[0].BackColor = Color.Transparent;
            cht4.ChartAreas[0].BorderColor = Color.Transparent;
            //X轴标签间距
            cht4.ChartAreas[0].AxisX.Interval = 1;
            cht4.ChartAreas[0].AxisX.LabelStyle.IsStaggered = true;
            cht4.ChartAreas[0].AxisX.LabelStyle.Angle = -45;
            cht4.ChartAreas[0].AxisX.TitleFont = new Font("微软雅黑", 20, FontStyle.Regular);
            cht4.ChartAreas[0].AxisX.TitleForeColor = Color.White;

            //X坐标轴颜色
            cht4.ChartAreas[0].AxisX.LineColor = ColorTranslator.FromHtml("#38587a"); ;
            cht4.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.White;
            cht4.ChartAreas[0].AxisX.LabelStyle.Font = new Font("微软雅黑", 20, FontStyle.Regular);
            //X坐标轴标题
            cht4.ChartAreas[0].AxisX.Title = "时间（点）";
            cht4.ChartAreas[0].AxisX.TitleFont = new Font("微软雅黑", 20, FontStyle.Regular);
            cht4.ChartAreas[0].AxisX.TitleForeColor = Color.White;
            cht4.ChartAreas[0].AxisX.TextOrientation = TextOrientation.Horizontal;
            cht4.ChartAreas[0].AxisX.ToolTip = "时间（点）";
            //X轴网络线条
            cht4.ChartAreas[0].AxisX.MajorGrid.Enabled = true;
            cht4.ChartAreas[0].AxisX.MajorGrid.LineColor = ColorTranslator.FromHtml("#2c4c6d");

            //Y坐标轴颜色
            cht4.ChartAreas[0].AxisY.LineColor = ColorTranslator.FromHtml("#38587a");
            cht4.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.White;
            cht4.ChartAreas[0].AxisY.LabelStyle.Font = new Font("微软雅黑", 20, FontStyle.Regular);
            //Y坐标轴标题
            cht4.ChartAreas[0].AxisY.Title = "数量(台)";
            cht4.ChartAreas[0].AxisY.TitleFont = new Font("微软雅黑", 20, FontStyle.Regular);
            cht4.ChartAreas[0].AxisY.TitleForeColor = Color.White;
            cht4.ChartAreas[0].AxisY.TextOrientation = TextOrientation.Rotated270;
            cht4.ChartAreas[0].AxisY.ToolTip = "数量(台)";
            //Y轴网格线条
            cht4.ChartAreas[0].AxisY.MajorGrid.Enabled = true;
            cht4.ChartAreas[0].AxisY.MajorGrid.LineColor = ColorTranslator.FromHtml("#2c4c6d");

            cht4.ChartAreas[0].AxisY2.LineColor = Color.Transparent;

            //背景渐变
            cht4.ChartAreas[0].BackGradientStyle = GradientStyle.None;

            //图例样式
            Legend legend4 = new Legend("#VALX");
            legend4.Title = "图例";
            legend4.TitleBackColor = Color.Transparent;
            legend4.BackColor = Color.Transparent;
            legend4.TitleForeColor = Color.White;
            legend4.TitleFont = new Font("微软雅黑", 20, FontStyle.Regular);
            legend4.Font = new Font("微软雅黑", 20, FontStyle.Regular);
            legend4.ForeColor = Color.White;

            cht4.Series[0].XValueType = ChartValueType.String;  //设置X轴上的值类型
            cht4.Series[0].Label = "#VAL";                //设置显示X Y的值
            cht4.Series[0].Font = new Font("微软雅黑", 20, FontStyle.Regular);
            cht4.Series[0].LabelForeColor = Color.White;
            cht4.Series[0].ToolTip = "#VALX:#VAL(台)";     //鼠标移动到对应点显示数值
            cht4.Series[0].ChartType = SeriesChartType.Column;    //图类型(柱状图)

            cht4.Series[0].Color = Color.Lime;
            cht4.Series[0].LegendText = legend4.Name;
            cht4.Series[0].IsValueShownAsLabel = true;
            cht4.Series[0].LabelForeColor = Color.White;
            cht4.Series[0].CustomProperties = "DrawingStyle = Cylinder";
            cht4.Series[0].CustomProperties = "PieLabelStyle = Outside";
            //cht4.Legends.Add(legend2);
            cht4.Legends[0].Position.Auto = false;
            cht4.Series[0].IsValueShownAsLabel = true;
            //是否显示图例
            cht4.Series[0].IsVisibleInLegend = true;
            cht4.Series[0].ShadowOffset = 0;

            //饼图折线
            cht4.Series[0]["PieLineColor"] = "White";
            //绑定数据
            cht4.Series[0].Points.DataBindXY(xCount, yCount);
            //cht4.Series[0].Points[0].Color = Color.White;     //cht4表，柱状图第一列的颜色
            //绑定颜色
            //cht4.Series[0].Palette = ChartColorPalette.BrightPastel;
            #endregion

            #region 稼动率

            //标题
            cht5.Titles.Add("稼动率数据分析");
            cht5.Titles[0].ForeColor = Color.White;
            cht5.Titles[0].Font = new Font("微软雅黑", 20, FontStyle.Regular);
            cht5.Titles[0].Alignment = ContentAlignment.TopCenter;
            //cht5.Titles.Add("合计：50" +
            //    "");
            //cht5.Titles[1].ForeColor = Color.White;
            //cht5.Titles[1].Font = new Font("微软雅黑", 8f, FontStyle.Regular);
            //cht5.Titles[1].Alignment = ContentAlignment.TopRight;

            //控件背景
            cht5.BackColor = Color.Transparent;
            //图表区背景
            cht5.ChartAreas[0].BackColor = Color.Transparent;
            cht5.ChartAreas[0].BorderColor = Color.Transparent;
            //X轴标签间距
            cht5.ChartAreas[0].AxisX.Interval = 1;
            cht5.ChartAreas[0].AxisX.LabelStyle.IsStaggered = true;
            cht5.ChartAreas[0].AxisX.LabelStyle.Angle = -45;
            cht5.ChartAreas[0].AxisX.TitleFont = new Font("微软雅黑", 20, FontStyle.Regular);
            cht5.ChartAreas[0].AxisX.TitleForeColor = Color.White;

            //X坐标轴颜色
            cht5.ChartAreas[0].AxisX.LineColor = ColorTranslator.FromHtml("#38587a"); ;
            cht5.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.White;
            cht5.ChartAreas[0].AxisX.LabelStyle.Font = new Font("微软雅黑", 20, FontStyle.Regular);
            //X坐标轴标题
            cht5.ChartAreas[0].AxisX.Title = "工位";
            cht5.ChartAreas[0].AxisX.TitleFont = new Font("微软雅黑", 20, FontStyle.Regular);
            cht5.ChartAreas[0].AxisX.TitleForeColor = Color.White;
            cht5.ChartAreas[0].AxisX.TextOrientation = TextOrientation.Horizontal;
            cht5.ChartAreas[0].AxisX.ToolTip = "工位";
            //X轴网络线条
            cht5.ChartAreas[0].AxisX.MajorGrid.Enabled = true;
            cht5.ChartAreas[0].AxisX.MajorGrid.LineColor = ColorTranslator.FromHtml("#2c4c6d");

            //Y坐标轴颜色
            cht5.ChartAreas[0].AxisY.LineColor = ColorTranslator.FromHtml("#38587a");
            cht5.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.White;
            cht5.ChartAreas[0].AxisY.LabelStyle.Font = new Font("微软雅黑", 20, FontStyle.Regular);
            //Y坐标轴标题
            cht5.ChartAreas[0].AxisY.Title = "稼动率(%)";
            cht5.ChartAreas[0].AxisY.TitleFont = new Font("微软雅黑", 15, FontStyle.Regular);
            cht5.ChartAreas[0].AxisY.TitleForeColor = Color.White;
            cht5.ChartAreas[0].AxisY.TextOrientation = TextOrientation.Rotated270;
            cht5.ChartAreas[0].AxisY.ToolTip = "稼动率(%)";
            //Y轴网格线条
            cht5.ChartAreas[0].AxisY.MajorGrid.Enabled = true;
            cht5.ChartAreas[0].AxisY.MajorGrid.LineColor = ColorTranslator.FromHtml("#2c4c6d");

            cht5.ChartAreas[0].AxisY2.LineColor = Color.Transparent;

            //背景渐变
            cht5.ChartAreas[0].BackGradientStyle = GradientStyle.None;

            //图例样式
            Legend legend5 = new Legend("#VALX");
            legend5.Title = "图例";
            legend5.TitleBackColor = Color.Transparent;
            legend5.BackColor = Color.Transparent;
            legend5.TitleForeColor = Color.White;
            legend5.TitleFont = new Font("微软雅黑", 20, FontStyle.Regular);
            legend5.Font = new Font("微软雅黑", 20, FontStyle.Regular);
            legend5.ForeColor = Color.White;

            cht5.Series[0].XValueType = ChartValueType.String;  //设置X轴上的值类型
            cht5.Series[0].Label = "#VAL";                //设置显示X Y的值   
            cht5.Series[0].Font  = new Font("微软雅黑", 20, FontStyle.Regular);
            cht5.Series[0].LabelForeColor = Color.White;
            cht5.Series[0].ToolTip = "#VALX:#VAL(%)";     //鼠标移动到对应点显示数值
            cht5.Series[0].ChartType = SeriesChartType.Spline;    //图类型(折线)

            cht5.Series[0].Color = Color.Lime;
            cht5.Series[0].LegendText = legend5.Name;
            cht5.Series[0].IsValueShownAsLabel = true;
            cht5.Series[0].LabelForeColor = Color.White;
            cht5.Series[0].CustomProperties = "DrawingStyle = Cylinder";
            cht5.Series[0].CustomProperties = "PieLabelStyle = Outside";
            //cht5.Legends.Add(legend2);
            cht5.Legends[0].Position.Auto = false;
            cht5.Series[0].IsValueShownAsLabel = true;
            //是否显示图例
            cht5.Series[0].IsVisibleInLegend = true;
            cht5.Series[0].ShadowOffset = 0;

            //饼图折线
            cht5.Series[0]["PieLineColor"] = "White";
            //绑定数据
            cht5.Series[0].Points.DataBindXY(xUtilization, yUtilization);
            cht5.Series[0].Points[0].Color = Color.White;
            //绑定颜色
            //cht5.Series[0].Palette = ChartColorPalette.BrightPastel;
            #endregion

        }
        string[] typeArray = new string[150];
        private void FormDesplay2_Load(object sender, EventArgs e)
        {
            this.label1.Parent = pictureBox2;
            this.label2.Parent = pictureBox1;
            this.label3.Parent = pictureBox1;
            this.label4.Parent = pictureBox1;
            this.label5.Parent = pictureBox1;
            this.label6.Parent = pictureBox1;
            this.label7.Parent = pictureBox1;
            this.label8.Parent = pictureBox1;
            this.label9.Parent = pictureBox1;
            this.label10.Parent = pictureBox1;
            this.label11.Parent = pictureBox1;
            this.label12.Parent = pictureBox1;
            this.label13.Parent = pictureBox1;
            this.label14.Parent = pictureBox1;
            this.label15.Parent = pictureBox1;
            this.label16.Parent = pictureBox1;
            this.label17.Parent = pictureBox1;
            this.label18.Parent = pictureBox1;
            this.label19.Parent = pictureBox1;
            this.label20.Parent = pictureBox1;
            this.label21.Parent = pictureBox1;
            this.label22.Parent = pictureBox1;
            this.label23.Parent = pictureBox1;
            

            this.cht1.Parent = pictureBox1;
            this.cht2.Parent = pictureBox1;
            this.cht3.Parent = pictureBox1;
            this.cht4.Parent = pictureBox1;
            this.cht5.Parent = pictureBox1;
            this.label1.Location = new System.Drawing.Point(30, 20);

            #region 向服务器获取所有产品型号和扫码设置
            string sql = "select [typeName] from MainData.dbo.parameterSetting";
            SqlDataReader objReader = SQLHelp.GetReader(sql);
            int temp2 = 0;
            while (objReader.Read())
            {
                typeArray[temp2] = objReader["typeName"].ToString();
                temp2 += 1;
            }
            objReader.Close();
            #endregion

            drow();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            string[] x = new string[] { "OP10", "OP20", "OP30", "OP40", "OP50", "OP60", "OP70", "OP80", "OP90", "OP100"/*, "OP110" */};
            double[] y = new double[] { FormMain.OP10[0],/* FormMain.OP10_2[0],*/ FormMain.OP20[0], FormMain.OP30[0], FormMain.OP40[0], FormMain.OP50[0], FormMain.OP60[0], FormMain.OP70[0], FormMain.OP80[0], FormMain.OP90[0], FormMain.OP100[0]/*, FormMain.OP110[0]*/};
            //double[] y = new double[] { 20, 30, 50, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105 };

            //string[] xCount = new string[] { "OP10", "OP20", "OP30", "OP40", "OP50", "OP60", "OP70", "OP80", "OP90", "OP100"/*, "OP110" */};
            //double[] yCount = new double[] { FormMain.OP10[1],/* FormMain.OP10_2[1],*/ FormMain.OP20[1], FormMain.OP30[1], FormMain.OP40[1], FormMain.OP50[1], FormMain.OP60[1], FormMain.OP70[1], FormMain.OP80[1], FormMain.OP90[1], FormMain.OP100[1]/*, FormMain.OP110[1]*/};
            string[] xCount = new string[] { FormMain.TimeRange[0], FormMain.TimeRange[1], FormMain.TimeRange[2], FormMain.TimeRange[3], FormMain.TimeRange[4], FormMain.TimeRange[5], FormMain.TimeRange[6], FormMain.TimeRange[7], FormMain.TimeRange[8], FormMain.TimeRange[9], FormMain.TimeRange[10], FormMain.TimeRange[11] };
            double[] yCount = new double[] { FormMain.TimeRangeValue[0], FormMain.TimeRangeValue[1], FormMain.TimeRangeValue[2], FormMain.TimeRangeValue[3], FormMain.TimeRangeValue[4], FormMain.TimeRangeValue[5], FormMain.TimeRangeValue[6], FormMain.TimeRangeValue[7], FormMain.TimeRangeValue[8], FormMain.TimeRangeValue[9], FormMain.TimeRangeValue[10], FormMain.TimeRangeValue[11] };
            //double[] yCount = new double[] { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 38, 37 };

            string[] xUtilization = new string[] { "OP10", "OP20", "OP30", "OP40", "OP50", "OP60", "OP70", "OP80", "OP90", "OP100"/*, "OP110"*/ };
            double[] yUtilization = new double[] { FormMain.OP10[2],/* FormMain.OP10_2[2],*/ FormMain.OP20[2], FormMain.OP30[2], FormMain.OP40[2], FormMain.OP50[2], FormMain.OP60[2], FormMain.OP70[2], FormMain.OP80[2], FormMain.OP90[2], FormMain.OP100[2]/*, FormMain.OP110[2]*/};

            string[] xCycleTime = new string[] { "OP10", "OP20", "OP30", "OP40", "OP50", "OP60", "OP70", "OP80", "OP90", "OP100"/*, "OP110" */};
            double[] yCycleTime = new double[] { FormMain.OP10[3], /*FormMain.OP10_2[3],*/ FormMain.OP20[3], FormMain.OP30[3], FormMain.OP40[3], FormMain.OP50[3], FormMain.OP60[3], FormMain.OP70[3], FormMain.OP80[3], FormMain.OP90[3], FormMain.OP100[3]/*, FormMain.OP110[3]*/};

            //绑定数据
            cht1.Series[0].Points.DataBindXY(x, y);
            cht1.Series[0].Points[0].Color = Color.White;
            cht1.Series[0].Palette = ChartColorPalette.Bright;
            cht1.Titles.RemoveAt(1);
            //右上角标题
            cht1.Titles.Add("一次合格率：" + FormMain.YCok[0]);
            //cht1.Titles.Add("合计：25414 宗");
            //cht1.Titles.Add("合计：25414 宗");
            //cht1.Titles.Add("合计：25414 宗");
            cht1.Titles[1].ForeColor = Color.White;
            cht1.Titles[1].Font = new Font("宋体", 20, FontStyle.Regular);
            //设置标题位于右上角
            cht1.Titles[1].Alignment = ContentAlignment.TopLeft;
            //cht1.Titles[2].Alignment = ContentAlignment.TopRight;
            //cht1.Titles[3].Alignment = ContentAlignment.TopRight;
            //cht1.Titles[4].Alignment = ContentAlignment.TopRight;

            //绑定数据
            cht2.Series[0].Points.DataBindXY(xCycleTime, yCycleTime);
            cht2.Series[0].Points[0].Color = Color.White;
            //绑定颜色
            //cht2.Series[0].Palette = ChartColorPalette.BrightPastel;

            //绑定数据
            cht4.Series[0].Points.DataBindXY(xCount, yCount);
            //cht4.Series[0].Points[0].Color = Color.White;
            //绑定颜色
            //cht4.Series[0].Palette = ChartColorPalette.BrightPastel;

            //绑定数据
            cht5.Series[0].Points.DataBindXY(xUtilization, yUtilization);
            cht5.Series[0].Points[0].Color = Color.White;
            //绑定颜色
            //cht5.Series[0].Palette = ChartColorPalette.BrightPastel;
            //型号
            try
            {
                label2.Text = typeArray[Convert.ToInt32(FormMain.YCok[2]) - 1];
            }
            catch (Exception)
            {
                //throw;
            }
            //计划数量
            label9.Text = FormMain.YCok[1].ToString();
            //实产数量
            label13.Text = FormMain.OP120[1].ToString();
            //完成率
            label15.Text = Math.Round((FormMain.OP120[1]/ FormMain.YCok[1]) * 100, 2).ToString();
            //预设节拍
            label18.Text = FormMain.YCok[3].ToString();
            //实际节拍
            label22.Text = FormMain.OP120[3].ToString();
            //稼动率
            label23.Text = FormMain.OP120[2].ToString();
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            this.label6.Text = DateTime.Now.ToString("yyyy/MM/dd");
            this.label7.Text = DateTime.Now.ToString("HH:mm:ss");
        }
    }
}
